﻿@{
    ViewBag.Title = "Daily Worklog";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="Breadcrumbs-Nav">
    <i class="fa fa-map-marker"></i>
    <a href="@Href("~/Reports/")">My Reports</a>
    Daily Worklog
</div>

<h2>Daily Worklog</h2>


<div class="staticTabbedBlock">
    <ul>
        <li class="active"><a href="@Href("~/Reports/DailyWorklog")">Daily Worklog</a></li>
        <li><a href="@Href("~/Reports/MonthlyWorklog")">Monthly Worklog</a></li>
    </ul>
    <div class="staticTabContent">
        <h3>@ViewBag.worklogRangeTitle</h3>
       
        <form id="Daily_Worklog_Form" name="Daily_Worklog_Form" method="post" action="">
           
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
                <tr>
                    <td width="17%" valign="top">Report month: </td>
                    <td width="83%" valign="top">
                        <select name="Worklog_Month" id="Worklog_Month">
                            <option value="01">January</option>
                            <option value="02">February</option>
                            <option value="03">March</option>
                            <option value="04">April</option>
                            <option value="05">May</option>
                            <option value="06">June</option>
                            <option value="07">July</option>
                            <option value="08">August</option>
                            <option value="09">September</option>
                            <option value="10">October</option>
                            <option value="11">November</option>
                            <option value="12">December</option>
                        </select>
                        <select name="Worklog_Year" id="Worklog_Year">
                            <option value="2015">2015</option>
                            <option value="2016">2016</option>
                            <option value="2017">2017</option>
                            <option value="2018">2018</option>
                            <option value="2019">2019</option>
                            <option value="2020">2020</option>
                        </select>
                        <input type="button" name="View_Report_Button" id="View_Report_Button" value="View" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><hr /><em>Shortcut: Alt+X to quick save the report</em></td>
                </tr>
                @for (int i = 1; i <= ViewBag.worklogDaysInMonth; i++)
                {
                    var tdStyle = " style=\"vertical-align:top;\"";
                    DateTime thisDate = new DateTime(Int16.Parse(ViewBag.worklogRange.Year.ToString()), Int16.Parse(ViewBag.worklogRange.Month.ToString()), i);
                    
                    if (thisDate.ToString("dddd") == "Saturday" || thisDate.ToString("dddd") == "Sunday")
                    {
                        tdStyle = " style=\"vertical-align:top; background-color:#EAEAEA\"";
                    }
                    if(thisDate.ToString("dd-MMM-yyyy")==DateTime.Now.ToString("dd-MMM-yyyy"))
                    {
                        tdStyle = " style=\"vertical-align:top; background-color:rgb(80, 192, 232)\"";
                    }  

                    <tr>
                        <td width="22%" valign="top" @Html.Raw(HttpUtility.HtmlDecode(tdStyle))><p><strong>@thisDate.ToString("dd MMMM yyyy, dddd")</strong></p></td>
                        <td width="78%" valign="top" @Html.Raw(HttpUtility.HtmlDecode(tdStyle))>
                            <textarea name="Report_@thisDate.ToString("yyyyMMdd")" id="Report_@thisDate.ToString("yyyyMMdd")" cols="100" rows="3"></textarea>
                        </td>
                    </tr>
                }
                <tr>
                    <td valign="top">&nbsp;</td>
                    <td valign="top"><input type="submit" name="Save_Report_Button" id="Save_Report_Button" value="Save Report" accesskey="x" /></td>
                </tr>
                </table>
        </form>
    </div>
</div>
<script>
    $("#View_Report_Button").click(function(){
    var searchMonth=$("#Worklog_Month").val();
        var searchYear=$("#Worklog_Year").val();
        window.location.href="@Href("~/Reports/DailyWorklog/Index/?year=")" + searchYear + "&month=" + searchMonth + "";
    });
</script>